#define _CRT_SECURE_NO_WARNINGS 1

struct ListNode* getIntersectionNode(struct ListNode* headA, struct ListNode* headB) {

    struct ListNode* curA = headA;
    struct ListNode* curB = headB;
    while (headA)
    {
        while (headB)
        {
            if (headA == headB)
            {
                return headA;
            }
            headB = headB->next;
        }
        headB = curB;
        headA = headA->next;
    }
    return NULL;
}